{/* Copyright 2025 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License. */}

import {Layout} from '../../src/Layout';
export default Layout;
import docs from 'docs:@react-aria/visually-hidden';
import {FunctionAPI} from '../../src/FunctionAPI';
import {InlineAlert, Heading, Content} from '@react-spectrum/s2';

export const section = 'Utilities';
export const description = 'Hides its children visually but keeps content accessible to screen readers.';

# VisuallyHidden

<PageDescription>{docs.exports.VisuallyHidden.description}</PageDescription>

```tsx
import {VisuallyHidden} from 'react-aria';

<VisuallyHidden>I am hidden</VisuallyHidden>
```

<InlineAlert variant="notice">
  <Heading>Positioning</Heading>
  <Content>VisuallyHidden is positioned absolutely, so it must have a `position: relative` or `position: absolute` ancestor. Otherwise, undesired scrollbars may appear.</Content>
</InlineAlert>

## API

### VisuallyHidden

<PropTable links={docs.links} component={docs.exports.VisuallyHidden} />

### useVisuallyHidden

For additional rendering flexibility, use the `useVisuallyHidden` hook . It supports the same
options as the component, and returns props to spread onto the element that should be hidden.

<FunctionAPI links={docs.links} function={docs.exports.useVisuallyHidden} />

## Example

See [useRadioGroup](RadioGroup/useRadioGroup.html#styling) and [useCheckbox](Checkbox/useCheckbox.html#styling)
for examples of using `VisuallyHidden` to hide native form elements visually.
